//
//  剑指 Offer 45. 把数组排成最小的数.swift
//  LeetCodeTrain
//
//  Created by rjb on 2021/9/1.
//  Copyright © 2021 rjb. All rights reserved.
//

import Foundation

class SolutionSord45 {
    // 最小的number
    // 采用排序就可以了
    func minNumber(_ nums: [Int]) -> String {
        var nums = nums
        nums.sort { a, b in
            let ab = "\(a)" + "\(b)"
            let ba = "\(b)" + "\(a)"
            return ab < ba
        }
        var result = ""
        for item in nums {
            result.append(String(item))
        }
        return result
    }
    static func test() {
        let solution = SolutionSord45()
        let nums = [1,2,3,4,5,6,7,8,9,0]
        let result = solution.minNumber(nums)
        print(result)
    }
}
